#/usr/bin/env python
from __future__ import unicode_literals
from __future__ import absolute_import


def type_fail(source, type_func, default):
    if isinstance(source, list) or isinstance(source, tuple):
        source = source[0]
    try:
        return type_func(source)
    except:
        return default
